﻿<!-OCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{% block title %}Taxi168{% endblock %}</title> 
{% block JS %}
<script type="text/javascript">
var timeout2=3 
String.format = function(src){
    if (arguments.length == 0) return null;
    var args = Array.prototype.slice.call(arguments, 1);
    return src.replace(/\{(\d+)\}/g, function(m, i){
        return args[i];
    });
};
function getCurLocation()
{
	//TODO: call the API of the phone to get the address
	location=new Object()
	location.longitude = 12
	location.latitude  = 14
	location.address   = "fake driver street"
	//alert("shit")
	return location
}

function setCurLocation(longitude,latitude,address)
{
	//TODO: call the API of the phone to get the address
	//alert("what is from Android")
	document.getElementById("longitude").value = longitude
	document.getElementById("latitude").value  = latitude
	document.getElementById("address").value   = address
	
	document.getElementById("newMsg").innerHTML = String.format("from Android:{0},{1},{2},{3}",longitude,latitude,address,document.getElementById("msgNotifyCounter").value)
}
function showPeerGPS(latitude,longitude,sessionID,pubID,onlyOneTime)
{
	//somehow, the android bundle can not process the phone number correctly,so change it to string explicitly
	strSessionID = String.format("sessionID={0}",sessionID)
	//alert(str1)
	androidTaxi168.OnShowPeerGPS(latitude,longitude,strSessionID,pubID,onlyOneTime)
}

function updateStatus()
{
	//alert("upshit")
  if (Number(document.getElementById("disableUpdateStatus").value==0))
  {
	  document.getElementById("status").value = document.getElementById("curStatus").value
	  location = getCurLocation()
	  document.getElementById("longitude").value = location.longitude
	  document.getElementById("latitude").value  = location.latitude
	  document.getElementById("address").value   = location.address
	  document.getElementById("formStatus").submit() 
	  //setTimeout('updateStatus()',3000)
	  
  }
  else if (document.getElementById('cancel'))
  {
	  if (Number(document.getElementById("timeoutInput").value)> 0)
	  {
		  document.getElementById("timeoutInput").value = Number(document.getElementById("timeoutInput").value)-timeout2
		  document.getElementById("timeoutLabel").innerHTML = document.getElementById("timeoutInput").value
	  }
	  else//cancel it
	  {
		  //document.getElementById("timeoutLabel").innerHTML = document.getElementById("timeoutInput").value
	  	  window.location = document.getElementById('cancel').href;	
	  }
  }
  
}

function confirmByHost(retCode)
{
	if (Number(retCode)==200)
	{
		window.location = document.getElementById('confirm').href;
	}
	else
	{
		window.location = document.getElementById('cancel').href;
	}
}

function onLoadFunc()
{
	setInterval('updateStatus()',timeout2*1000);	
	notifyNewMsg();
}
function notifyNewMsg()
{
	//document.getElementById("confirm").innerHTML = "语音提示中"//String.format("调用{0}{1}",document.getElementById("newMsgID").value,document.getElementById("newMsg").value)
	if (Number(document.getElementById("newMsgID").value)!= 0)
	{
		var id = document.getElementById("newMsgID").value
		document.getElementById("newMsgID").value = 0
		androidTaxi168.OnNewMsg(id, document.getElementById("newMsg").value)
	}
}



</script> 
{% endblock %}
<style type="text/css">
.style1 {
	text-align: center;
}
</style>
</head>
<body {% block onload %}{% endblock %}>


{% block menu %}{% endblock %}
{% block content %}

	{% for service in serviceList %}   
	
	   <h4>订单号:{{service.pubID}}&nbsp;&nbsp;&nbsp; 
	   		{%if service.action%}
	   		<a href="/action/?sessionID={{sessionID}}&pubID={{service.pubID}}&retCode=200&action={{service.action.name}}" id='confirm'>{{service.action.chineseName}}</a>
	   		&nbsp;&nbsp;&nbsp;
	   		{%if service.action.cancelName%}
	   		<a href="/action/?sessionID={{sessionID}}&pubID={{service.pubID}}&retCode=406&action={{service.action.name}}" id='cancel'>{{service.action.cancelName}}</a>
	   		{%endif%}
	   		{%endif%}
	   		{%if service.inform.msg%} 
	   		<input name="newMsgID" id="newMsgID" type="hidden" value={{service.inform.msgID}} />
	   		<input name="newMsg" id="newMsg" type="hidden" value="{{service.inform.msg}}" />
	   		{%endif%}
	   		{%if service.action2%}
	   		<input name="{{service.action2.name}}" type="button" value="{{service.action2.chineseName}}"  id="action2" onclick="{{service.action2.jsFunc}}"/>
	   		{%endif%}
	   		
	   </h4>
		<h4>出发:{{service.getDepartText2}}</h4>
		<h4>出发时间:{{service.getDepartTimeText2}}</h4>
		<h4>目的:{{service.getDestText2}}</h4>
		<h4>状态:{{service.getStatusText2}}</h4>
		{%if service.action.cancelName%}
		<input name="timeoutInput" id="timeoutInput" type="hidden" value={{service.action.timeout}} />
		<h4>有效确认时间:<label id='timeoutLabel' >{{service.action.timeout}}</label> 秒</h4>
		<h4><a href="/action/?sessionID={{sessionID}}&pubID={{service.pubID}}&action=getNotify">完整信息</a></h4>
		{%endif%}
		<br/>
	{% endfor %}  


{% endblock %}
{% block updateInfo %}
 
<div id="divUD" style="display: none;">
    <iframe name='ifrmUS' allowTransparency='true' frameborder='0' src='about:blank'></iframe>
    </div>
<!-- target="ifrmUS" -->

<input name="msgNotifyCounter" id="msgNotifyCounter" type="hidden" value=0 />
<input name="disableUpdateStatus" id="disableUpdateStatus" type="hidden" value={{disableUpdateStatus}} /> 
<input name="curStatus" id="curStatus" type="hidden" value={{curStatus}} />
<form name="formStatus" id="formStatus" method="post" action="/updateStatus/"  style="height: 288px" >
<input name="status" id="status" type="hidden" value=0 />
<input name="longitude" id="longitude" type="hidden" value=0 />
<input name="latitude" id="latitude" type="hidden" value=0 />
<input name="address" id="address" type="hidden" value="unknown" />
<input name="sessionID" id="sessionID" type="hidden" value={{sessionID}} /> 
</form>
{% endblock %}
{% block hideInfo %}

{% endblock %}
{% block footer %}</br></br>{{counter}}</br>{% endblock %}	
</body>
</html>
